#!/usr/bin/python
# -*- coding: utf-8 -*-
while True:

    n1,n2=map(int,raw_input().split())
    ll=[]
    res=[]
    i=0
    while(i<n1):
        ll.append(raw_input())
        i+=1
#l1,l2=map(int,raw_input().split())
#c1,c2=map(int,raw_input().split())
    maxlength=0
    for i in range(n1):
        ss=list(ll[i])
        if ss.count('*')>maxlength:
            maxlength=ss.count('*')
            break
#print maxlength

    for i in range(n1):
        ss=list(ll[i])
    #print ss
        if ss.count('*')==0:continue
        else:
            for j in range(n2):
                if ss[j]=='.':pass
                else:
                    res.append(ss[j:j+maxlength])
                    break
#print res
#print(ll)
#print len(ll)
#print len(ll[0])
    for i in range(len(res)):
        st=""
        stt=st.join(res[i])
        print(stt)
